feat(driver): add Cloudflare Image Bed support#2427
Conversation
|
可能违反使用政策 |
不好意思 不熟悉流程,急于询问相关要求 所以提了个 issue。入门试一试,前端构建文件忘记弄回去了 |
应该没有吧,单纯看使用者使用什么存储后端,比如我自己是用 S3和 Cloudflare 自己的对象存储,完全合规。较少使用Huface 和 telegram 存储文件 |
- Rename driver identifier and directory to 'cloudflare_imgbed' for consistency. - Remove invalid 'replace' directive in go.mod. - Restore accidentally modified/deleted files in public/dist. - Update driver registration in drivers/all.go. Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
…tion with improved error handling and pagination
|
不好意思 刚刚在调试 build 工作流 拉 snap 老是不成功 |
|
已考虑和测试,无法实现大于 100 MB 的文件上传,受限于 cloud flare,故才来提交这个新驱动 而且其实在 AI 的帮助下,上传逻辑也写好了,不过感觉测试还不够充分,我只简单地测试了一下,上传大于 100mb 的文件成功了,目前是处于能用的阶段, 但是我感觉写法不够完善,担心可能增加您审核的负担,三天后 我又要开学了🥲 |
|
@j2rong4cn 您好 看到您标记为草稿我以为我写得不好来着 已经在改了 刚才在搞上传相关的逻辑,这里也有一些变动,避免重复修改,推荐您等我写好完整的再一起看吧,应该快完成了 |
|
分片上传参考可以这个,stream.NewStreamSectionReader + errgroup.NewOrderedGroupWithContext OpenList/drivers/123_open/upload.go Lines 45 to 172 in 7e37c40 |
…performance - Added support for standard multipart form upload with zero-copy streaming. - Implemented HuggingFace LFS direct upload for large files (>20MB). - Integrated with OpenList global rate limiter and progress tracking. - Optimized memory usage using io.MultiReader for request body construction. - Added configurable upload threads for chunked HF uploads. - Support auto mkdir dir when in upload
|
@j2rong4cn 您好 已经完成上传模块编写并且测试完成,正是学习123open。
|
|
路径处理其实很简单的,你看着改吧dc74222 |
|
Obj的ID和Path只在当前驱动使用,List返回什么值,Put、Link等方法就会收到什么 |
感谢指导,之前吃了亏。现已精简逻辑,确实可运行 |
…prove initialization logic
|
我没测试 |
docs: update help descriptions to English in cloudflare_imgbed
Store a cleanup handle alongside weak pointers and stop previous cleanups when overwriting entries to avoid stale removals and leaked cleanup handlers. Ensure Delete signals success and stops associated cleanup. Add Clear to stop all active cleanups. Use entry identity in the cleanup callback to avoid removing newly inserted values.
There was a problem hiding this comment.
Pull request overview
This PR adds a new storage driver integrating Cloudflare Image Bed (Cloudflare Workers-based image hosting) into OpenList, including support for listing, direct links, and uploads (with optional HuggingFace LFS direct upload for large files). It also introduces an internal weak-reference cache utility to manage virtual directories without manual cleanup goroutines.
Changes:
- Added
cloudflare_imgbeddriver with List/Link/Remove/MakeDir/Put (standard multipart upload + HuggingFace direct/chunked upload). - Added a generic
WeakCacheMap(weak refs +runtime.AddCleanup) to store ephemeral virtual directory objects. - Registered the new driver in the global drivers list.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
internal/cache/weak_cache.go |
Adds a generic weak-reference cache map used to track virtual objects with GC-based cleanup. |
drivers/cloudflare_imgbed/driver.go |
Implements core driver methods (Init/Drop/List/Link/Get/MakeDir/Remove) and virtual dir handling. |
drivers/cloudflare_imgbed/meta.go |
Defines driver addition/config metadata and registers the driver. |
drivers/cloudflare_imgbed/types.go |
Adds API response types and metadata parsing helpers for listing. |
drivers/cloudflare_imgbed/util.go |
Adds a shared Resty request helper with retries and API error parsing. |
drivers/cloudflare_imgbed/upload.go |
Implements standard multipart upload and HuggingFace direct (incl. chunked) upload + commit. |
drivers/all.go |
Registers the new cloudflare_imgbed driver import. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: j2rong4cn <36783515+j2rong4cn@users.noreply.github.com>
Adds an uploadFolder query parameter to forward the destination path to the backend. Replaces the fixed-size sample read with a streaming base64 encoder to avoid truncation and reduce allocations Co-authored-by: Copilot <copilot@github.com>
|
@ZZ0YY |
太谢谢您了 我在备考高考 要鸽到考完再继续了。°o |












Description / 描述
目前实现了列表和下载功能,上传功能后续再做,已完成列表,下载,上传,上传时自动创建文件夹先提一个 PR,看看意见Add a new storage driver for Cloudflare Image Bed https://github.com/MarSeventh/CloudFlare-ImgBed
(a popular image hosting solution based on Cloudflare Workers & KV/D1).
Features implemented:
RootPath(subdirectory) mounting.为 Cloudflare Image Bed
https://github.com/MarSeventh/CloudFlare-ImgBed
(基于 Cloudflare Workers 和 KV/D1 的图床方案)新增存储驱动。
实现功能:
Motivation and Context / 背景
Cloudflare Image Bed is a lightweight and free-tier-friendly image hosting tool. Integrating it into OpenList allows users to manage their Cloudflare-based image assets alongside other storage services.
Cloudflare Image Bed 是一个轻量且对免费用户友好的图床工具。通过将其集成到 OpenList,用户可以方便地与其他存储服务一起管理其在 Cloudflare 上的图片资产。
Relates to #376 (Add more storage drivers)
How Has This Been Tested? / 测试
Environment: Go 1.24, Windows 10.
Manual Test:
RootPath.Debug: Used
restydebug mode to ensure HTTP requests/responses are handled correctly.环境:Go 1.24, Windows 10。
手动测试:
调试:开启
resty的调试模式,确保 HTTP 请求和响应逻辑无误。Checklist / 检查清单
我已阅读 CONTRIBUTING 文档。
go fmt.我已使用
go fmt格式化提交的代码。我已为此 PR 添加了适当的标签。
我已相应更新了相关仓库。